using DA.AnimGraph;
using UnityEngine;

namespace DA.AnimGraph.Editor {

    [NodeMenuItem(typeof(AGANode_Slot), "Slot")]
    internal class NodeView_Slot : NodeViewBase {
        public override string titleText => "Slot";
        protected override NodeViewInspectorSourceBase dataSource => inspectorData;
        NodeViewInspector_Slot inspectorData;

        internal override void Init(AGAHandle_Node handle, AnimGraphView graphView, AGEEnvironment ageContext) {
            SetTitleColor(new Color(0.24f, 0.5f, 0.6f, 0.6f));
            inspectorData = new NodeViewInspector_Slot();
            inspectorData.SetHandle(handle);
            base.Init(handle, graphView, ageContext);
        }
    }

    internal class NodeViewInspector_Slot : NodeViewInspectorSourceBase {
        [InspectorField(label: "slot名")] public RefField<string> slotName;
        [InspectorField(label: "过渡时间")] public RefField<float> defaultDuration;


        protected override void LoadFromModel() {
            var model = handleKeeper.handle.data.modelProperty as AGANodeModel_Slot;
            slotName = new RefField<string>(model.slotName);
            defaultDuration = new RefField<float>(model.defaultDuration);

        }

        protected override void SaveToModel() {
            handleKeeper.handle.ModifyModel(m => {
                var model = m as AGANodeModel_Slot;
                model.slotName = slotName.value;
                model.defaultDuration = defaultDuration.value;
            });
        }
    }


}